using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace Spacedash.Logic.Scenario.Cells.Actions
{
    sealed class CellTypes
    {
        public const string Brake = "brake";
        public const string Accelerate = "accel";
    }
    /// <summary>
    /// CellAction allows a CellData to have some logic associated to the player's interactions (when they pass over the cell)
    /// They are loaded from a XML node, so the effects can be customized.
    /// </summary>
    public abstract class CellAction
    {
        /// <summary>
        /// Executes the action when the specified ship passes over the cell
        /// </summary>
        /// <param name="ship">Ship passing over the cell</param>
        public abstract void Execute(Ship ship);

        /// <summary>
        /// Gets an action loaded from the specified xml node
        /// </summary>
        /// <param name="xn">Xml node with action information</param>
        /// <returns>Associated CellAction (if any)</returns>
        public static CellAction loadAction(XmlNode xn)
        {
            switch (xn.Name)
            {
                case CellTypes.Brake:
                    return new BrakeCellAction(xn);
                case CellTypes.Accelerate:
                    return new AccelCellAction(xn);
            }
            return null;
        }
    }
}
